﻿using System;
using System.Collections;
using System.Collections.Generic;
using LinQProject;
using LinQProject.Repository;


namespace ServiceProject.EntityService
{
    public class ClientService:DataBaseProcessBase<Client>
    {
        public ClientService(FarmacieDataClassesDataContext database) : base(database)
        {}

        public object InsertClient(Client client)
        {
            return base.Add(client, "ClientId");
        }

        public Client GetClientByUser(User user, Guid? userId)
        {
           if (user == null && userId == null)
             return null;

           Guid userIdToFind = user == null ? (Guid)userId : user.UserId;
           IList<Client> listUser = base.GetAll(c => c.UserId == userIdToFind);
           if (listUser.Count > 0)
               return listUser[0];
           return null;
        }
    }
}
